Socket
Socket
Sign inDemoInstall

lilconfig

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lilconfig

A zero-dependency alternative to cosmiconfig


Version published
Weekly downloads
28M
increased by6.14%
Maintainers
1
Weekly downloads
 
Created

What is lilconfig?

The lilconfig npm package is a lightweight utility for loading configuration files for Node.js projects. It allows developers to search for and read configuration files in various formats from the file system, providing a simple API to work with project configurations.

What are lilconfig's main functionalities?

Searching for configuration files

This feature allows you to search for configuration files related to 'myapp' in the project directory and its parent directories. The search method returns a promise that resolves with the result object containing the file path and its contents if found.

const lilconfig = require('lilconfig');
lilconfig('myapp').search().then(result => {
  console.log(result);
});

Loading configuration from a specific file

This feature allows you to load configuration from a specific file. The load method returns a promise that resolves with the result object containing the file path and its parsed contents.

const lilconfig = require('lilconfig');
lilconfig('myapp').load('path/to/config.json').then(result => {
  console.log(result);
});

Custom loaders for different file formats

This feature allows you to define custom loaders for different file formats. In this example, a custom loader for YAML files is provided using the 'yaml' npm package. The search method will use this loader when a '.yaml' file is encountered.

const lilconfig = require('lilconfig');
const yaml = require('yaml');
const loaders = {
  '.yaml': async filepath => {
    const content = await fs.promises.readFile(filepath, 'utf8');
    return yaml.parse(content);
  }
};
lilconfig('myapp', { loaders }).search().then(result => {
  console.log(result);
});

Other packages similar to lilconfig

Keywords

FAQs

Package last updated on 02 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc